//
//  App.swift
//  JXBaseTools_Example
//
//  Created by godox on 2021/12/11.
//  Copyright © 2021 CocoaPods. All rights reserved.
//

import Foundation

///控制版本信息
public struct App {
    
    ///当前版本
    public static var version: String = {
        var version: String = ""
        if let infoDictionary = Bundle.main.infoDictionary {
            version = infoDictionary["CFBundleShortVersionString"] as! String
        }
        return version
    }()
    
    /// 当前版本的build
    public static let build: String = {
        var build: String = ""
        if let infoDictionary = Bundle.main.infoDictionary {
            build = infoDictionary["CFBundleVersion"] as! String
        }
        return build
    }()

    
    /// 保存的版本信息
    public static var saveVersion: String? {
        
        set {
            UserDefaults.standard.setValue(newValue, forKey: "saveVersion")
        }
        get {
            return UserDefaults.standard.string(forKey: "saveVersion")
        }
    }
    
    public static var isAppStart: Bool? {
        
        set {
            UserDefaults.standard.setValue(newValue, forKey: "isAppStart")
        }
        get {
            return UserDefaults.standard.bool(forKey: "isAppStart")
        }
    }
    
    public static var isNeedDelete: Bool? {
        
        set {
            UserDefaults.standard.setValue(newValue, forKey: "isNeedDelete")
        }
        get {
            return UserDefaults.standard.bool(forKey: "isNeedDelete")
        }
    }
    
    public static var isNeedMaskView: Bool? {
        
        set {
            UserDefaults.standard.setValue(newValue, forKey: "isNeedMaskView")
        }
        get {
            return UserDefaults.standard.bool(forKey: "isNeedMaskView")
        }
    }
    
    
    /// App名称
    public static var name: String {
        
        var name: String = ""
        if let infoDictionary = Bundle.main.infoDictionary {
            name = infoDictionary["CFBundleDisplayName"] as! String
        }
        return name
    }
    
    ///系统版本号
    public static var systemVersion: String {
        
        return UIDevice.current.systemVersion
    }
    
    ///设备名称
    public static var systemName: String {
        return UIDevice.current.systemName
    }
    
    ///设备具体型号
    public static var na: String {
        return UIDevice.current.name
    }
    
    public static var uuid: String {
        return UIDevice.current.identifierForVendor!.uuidString
        
    }
}
